#pragma once
#include "DXContext.h"
#include "VertexLayout.h"

namespace DXBase
{
	namespace D3D
	{
	    [Windows::Foundation::Metadata::WebHostHidden]
		public ref class VertexShader sealed : IContextBound
		{
		internal:
			virtual void LoadDXData() = IContextBound::LoadDXData;
			virtual void ClearDXData() = IContextBound::ClearDXData
			{
				mBasicInputLayout = nullptr; 
				mBasicVertexShader = nullptr; 
			}
			virtual property DXContext^ Context
			{
				DXContext^ get() = IContextBound::Context::get { return watcher.Context; } 
				void set(DXContext^ ctxt) = IContextBound::Context::set { watcher.Context = ctxt; }
			}

		public:
			VertexShader();
			property DXBase::D3D::VertexLayout^ VertexLayout { DXBase::D3D::VertexLayout^ get() { return mLayout; } }

			void LoadShaderFile(DXBase::D3D::VertexLayout^ layout, Platform::String^ file);
			// it's empty if no shader file have been loaded
			property bool IsEmpty { bool get() { return shader_bytecode == nullptr; } }

		private:
			DXBase::ContextWatcher watcher;
			DXBase::D3D::VertexLayout^ mLayout;
			Platform::Array<byte>^ shader_bytecode;

		internal:
			Microsoft::WRL::ComPtr<ID3D11InputLayout>  mBasicInputLayout;   
			Microsoft::WRL::ComPtr<ID3D11VertexShader> mBasicVertexShader;  
		};

	    [Windows::Foundation::Metadata::WebHostHidden]
		public ref class PixelShader sealed : IContextBound
		{
		internal:
			virtual void LoadDXData() = IContextBound::LoadDXData;
			virtual void ClearDXData() = IContextBound::ClearDXData { mBasicPixelShader = nullptr; }
			virtual property DXContext^ Context
			{
				DXContext^ get() = IContextBound::Context::get { return watcher.Context; } 
				void set(DXContext^ ctxt) = IContextBound::Context::set { watcher.Context = ctxt; }
			}

		public:
			PixelShader();

			void LoadShaderFile(Platform::String^ file);
			// it's empty if no shader file have been loaded
			property bool IsEmpty { bool get() { return shader_bytecode == nullptr; } }

		private:
			DXBase::ContextWatcher watcher;
			Platform::Array<byte>^ shader_bytecode;

		internal:
			Microsoft::WRL::ComPtr<ID3D11PixelShader>  mBasicPixelShader;   
		};
	}
}